package com.fcscs.cservice.domain;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.fcscs.core.domain.HistoricalEntity;
import com.fcscs.cservice.common.CServiceCommonEnums;
import com.fcscs.cservice.common.CServiceConstants;
import com.fcscs.share.common.ShareEnums.WSSource;

public class BookingBase extends HistoricalEntity{
	
	/**
	 * BookingBase
	 */
	private static final long serialVersionUID = -3167576987257015010L;
	private long restaurantId;
	private Long reservationId;
	private long guestProfileId;
	private Date reservationDate;
	private Date arrivalDate;
	private Date departureDate;
	private CServiceCommonEnums.BookingStatus bookingStatus;
	private CServiceCommonEnums.GuestProfileType guestType;
	private int numberOfGuest;
	private String notify;
	private List<CServiceCommonEnums.NotifyType> notifyList;
	private Boolean smoking;
	private String note;
	private WSSource source;
	
	public long getRestaurantId() {
		return restaurantId;
	}

	public void setRestaurantId(long restaurantId) {
		this.restaurantId = restaurantId;
	}

	public void setReservationId(Long reservationId) {
		this.reservationId = reservationId;
	}

	public Long getReservationId() {
		return reservationId;
	}

	public long getGuestProfileId() {
		return guestProfileId;
	}

	public void setGuestProfileId(long guestProfileId) {
		this.guestProfileId = guestProfileId;
	}

	public Date getReservationDate() {
		return reservationDate;
	}

	public void setReservationDate(Date reservationDate) {
		this.reservationDate = reservationDate;
	}

	public Date getArrivalDate() {
		return arrivalDate;
	}

	public void setArrivalDate(Date arrivalDate) {
		this.arrivalDate = arrivalDate;
	}

	public Date getDepartureDate() {
		return departureDate;
	}

	public void setDepartureDate(Date departureDate) {
		this.departureDate = departureDate;
	}

	public String getBookingStatus() {
		return bookingStatus == null ? null : bookingStatus.toString();
	}
	
	public CServiceCommonEnums.BookingStatus getBookingStatusEnum() {
		return bookingStatus;
	}
	
	public void setBookingStatus(String bStatus) {
		if (bStatus == null) {
			this.bookingStatus = null;
		} else {
			this.bookingStatus = CServiceCommonEnums.BookingStatus.valueOf(bStatus);
		}
	}

	public void setBookingStatus(CServiceCommonEnums.BookingStatus bookingStatus) {
		this.bookingStatus = bookingStatus;
	}

	public CServiceCommonEnums.GuestProfileType getGuestTypeEnum(){
		return guestType;
	}
	
	public String getGuestType() {
		return guestType == null? null : guestType.toString();
	}

	public void setGuestType(CServiceCommonEnums.GuestProfileType guestType){
		this.guestType = guestType;
	}
	
	public void setGuestType(String guestType) {
		if (guestType == null) {
			this.guestType = null;
		} else {
			this.guestType = CServiceCommonEnums.GuestProfileType.valueOf(guestType);
		}
	}

	public int getNumberOfGuest() {
		return numberOfGuest;
	}

	public void setNumberOfGuest(int numberOfGuest) {
		this.numberOfGuest = numberOfGuest;
	}

	public String getNotify() {
		if(notifyList.size() !=0 ){
			StringBuffer sb = new StringBuffer();
			for(CServiceCommonEnums.NotifyType s : notifyList){
				sb.append(s+CServiceConstants.DATA_LINK);
			}
			notify = sb.toString().substring(0, sb.length()-1);
		}
		return notify;
	}

	private void setNotify(String notify) {
		this.notify = notify;
	}

	public List<CServiceCommonEnums.NotifyType> getNotifyList() {
		List<CServiceCommonEnums.NotifyType> lit = new ArrayList<CServiceCommonEnums.NotifyType>();
		if (notify != null) {
			String[] nfiy = notify.split(CServiceConstants.SPLIT_MARK);
			for (String s : nfiy) {
				lit.add(CServiceCommonEnums.NotifyType.valueOf(s));
			}
		}
		notifyList = lit;
		return notifyList;
	}

	public void setNotifyList(List<CServiceCommonEnums.NotifyType> notf) {
		if(notf.size() != 0){
			StringBuffer sb = new StringBuffer();
			for(CServiceCommonEnums.NotifyType s : notf){
				sb.append(s+CServiceConstants.DATA_LINK);
			}
			setNotify(sb.toString().substring(0, sb.length()-1));
		}else{
			setNotify(null);
		}
		this.notifyList = notf;
	}

	public Boolean getSmoking() {
		return smoking;
	}

	public void setSmoking(Boolean smoking) {
		this.smoking = smoking;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}
	
	public WSSource getSourceEnum() {
		return source;
	}
	
	public void setSourceEnum(WSSource source) {
		this.source = source;
	}
	
	public String getSource() {
		return source == null ? null : source.toString();
	}
	
	public void setSource(String source) {
		this.source = source == null ? null : WSSource.valueOf(source);
	}

	@Override
	public DBLoc getDBLoc() {
		return DBLoc.GUEST;
	}
}
